home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / DLFCN.ZIP / dlfcn / octave / safe-stat.h < prev    next >
C/C++ Source or Header  |  1997-08-20  |  2KB  |  68 lines

  1. /* safe-stat.h -- EINTR-safe interface to stat
  2.    Copyright (C) 1994 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.    
  18. /* Written by Jim Meyering <meyering@comco.com>.  */
  19.  
  20. #ifndef _safe_stat_h_
  21. #define _safe_stat_h_ 1
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27. /* NOTE: you must include the following headers (in the listed order)
  28.    before this one: <sys/types.h>, <sys/stat.h>.  */
  29.  
  30. #include <errno.h>
  31.  
  32. #ifndef errno
  33. extern int errno;
  34. #endif
  35.  
  36. #ifndef __GNUC__
  37. #define __inline /* empty */
  38. #endif
  39.  
  40. /* On some systems, stat can return EINTR.  */
  41.  
  42. #ifndef EINTR
  43. # define SAFE_STAT(name, buf) stat (name, buf)
  44. #else
  45. # ifndef __static
  46. #   define __static static
  47. # endif
  48. # define SAFE_STAT(name, buf) safe_stat (name, buf)
  49. __static __inline int
  50. safe_stat (const char *name, struct stat *buf)
  51. {
  52.   int ret;
  53.  
  54.   do
  55.     ret = stat (name, buf);
  56.   while (ret < 0 && errno == EINTR);
  57.  
  58.   return ret;
  59. }
  60. #endif
  61.  
  62.  
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66.  
  67. #endif /* _safe_stat_h_ */
  68.